<template>
	<view class="content">
		<u-navbar back-text="" slot="center" :autoBack="true" safeAreaInsetTop placeholder>
			<view slot="center" class="leftText">完善信息</view>
		</u-navbar>
		<view class="form">
			<u--form
				labelPosition="left"
				:model="form"
				:rules="rules"
				ref="form1"
				:labelStyle="{'font-size':'28rpx','color':'#424242'}"
			>
		
				<view class="ico-item poser" @click="navAddMaps">
					<view class="item-label">项目地址</view>
					<view class="item-poser dis-row">
						<view class="jsm">{{cutstr(form.address,35)}}</view>
						<view class="icoimg"><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/icon/jt2.png"></image></view>
					</view>
				</view>
				
				<view class="ico-item poser" @click="showGZ">
					<view class="item-label">所需工种</view>
					<view class="item-poser dis-row">
						<view class="jsm">{{cutstr(form.worktype,60)}}</view>
						<view class="icoimg"><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/icon/jt2.png"></image></view>
					</view>
				</view>
				
				<!-- <u-form-item label="所需工种" required labelWidth="100" prop="userInfo.range" borderBottom>
					<u-input v-model="form.worktype" inputAlign="right"  border="none"></u-input>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item> -->
				<view class="work_type poser" v-for="(item, index) in gongzhong" :key="index" >
					<!-- <view class="top" @click="addGongzhong"> -->
					<view class="top">
						<view class="work_type_name">
							<view>{{item.skillName}}</view>
							<view v-if="item.child && item.child.personName">{{item.child.personName}}</view>
						</view>
					</view>
					<view class="bottom" v-if="item.child">
						<view v-if="item.child && item.child.personNumName">{{item.child.personNumName}}人</view>
						<view v-if="item.child && item.child.countName">{{item.child.countName}}</view>
						<view class="t1" v-if="item.child.gznum && item.child.gznum!=0">{{item.child.gznum}}{{item.child.id==3?item.child.gztypeName:'元'}}</view>
						<view v-if="item.child.gongqiName">{{item.child.gongqiName}}</view>
						<view v-if="item.child.ageName">{{item.child.ageName}}</view>
					</view>
					<!-- <view class="tinxieInfo dis-row" @click="addGongzhong(item,index)" v-if="!item.child"> -->
					<view class="tinxieInfo dis-row" @click="addGongzhong(item,index)">
						<text>{{item.child?'修改信息':'填写信息'}}</text>
						<label><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/icon/jt2.png"></image></label>
					</view>
				</view>
				
				<u-form-item label="职位要求" labelWidth="100" prop="userInfo.range" borderBottom>
					<view class="postionList" @click="openPostion()" v-if="selectzhiye && selectzhiye.length>0" > 
						<text v-for="(k,v) in selectzhiye" :key="v">{{k.jobReq}}</text>
					</view>
					<view class="postionList" @click="openPostion()" v-if="!selectzhiye || selectzhiye.length==0">
						<view class="pol">请选择</view>
					</view>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>

				
				<u-form-item label="福利待遇" labelWidth="100" prop="userInfo.range" borderBottom>
					<view class="postionList" @click="openTreatment()" v-if="selectfuli && selectfuli.length>0"> 
						<text v-for="(k,v) in selectfuli" :key="i">{{k.welfare}}</text>
					</view>
					<view class="postionList" @click="openTreatment()" v-if="!selectfuli || selectfuli.length==0">
						<view class="pol">请选择</view>
					</view>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>
				<view style="width: 100%;" @click="textareaNo">
				<u-form-item label="工作描述"  labelWidth="100" prop="userInfo.range" borderBottom>
					<u--input v-model="form.workDis" inputAlign="right" disabled="true" disabledColor="#ffffff"  border="none"></u--input>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>
				</view>
				<u-form-item label="联系人"  labelWidth="100" prop="userInfo.range" borderBottom>
					<u--input v-model="form.name" maxlength='10' disabledColor="#0F0F0F" inputAlign="right"  border="none" placeholder="请填写姓名"></u--input>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>
				<view style="width: 100%;height: 90rpx;" @click="addNewPhone">
					<u-form-item label="联系电话" labelWidth="100" prop="userInfo.range" borderBottom >
						<u--input v-model="form.tel" inputAlign="right" disabled="true" disabledColor="#ffffff"  border="none" placeholder="请填写电话" ></u--input>
						<u-icon slot="right" name="arrow-right"></u-icon>
					</u-form-item>
				</view>
				<view style="width: 100%;height: 90rpx;" @click="openTelTime">
				<u-form-item label="接电话时间" labelWidth="100" placeholder="请选择可接电话时间" prop="form.teltime" borderBottom ref="item1">
					<u--input v-model="form.teltime" disabled="true" disabledColor="#ffffff" inputAlign="right" border="none" placeholder="请选择时间" ></u--input>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>
				</view>
			</u--form>
			<view class="imageUpload">
				<view>上传图片</view>
				<view>可上传工地现场、施工图纸、承包合同等图片</view>
			</view>
			<u-upload
				:fileList="fileList1"
				@afterRead="afterRead"
				@delete="deletePic"
				name="1"
				multiple
				:maxCount="3"
				:previewFullImage="true"
			></u-upload>
			<view class="relBut">
				<view @click="sendnow(1)">置顶发布</view>
				<view @click="sendnow(0)">发布好活</view>
			</view>
		</view>
		
		<u-popup
			:show="telTime"
			:round="10" 
			mode="bottom" 
			:closeable="true" 
			@close="closeTelTime" 
			>
			<view class="telTime">
				<view class="telTimeTitle">在此时间段工人才能电话联系您</view>
				<view class="list">
					<view v-for="(item,index) in answerTelDate" @click="choiceDate(index)" :key="index" :class="item.curIndex==1?'active':''">{{item.name}}</view>
				</view>
				<u-button type="primary" @click="closeTelTimeSure()" customStyle="background:#0575FF; font-size:32rpx;" text="确定"></u-button>
			</view>
		</u-popup>
		
		<u-popup
			:show="postion" 
			:round="10" 
			mode="bottom" 
			:closeable="true" 
			@close="closePostion" 
			>
			<view class="but">
				<view class="butTitle">请选择职位要求</view>
				<view class="list">
					<view v-for="(item,index) in postionDate" @click="choicePostion(index)" :key="index" :class="item.curIndex==1?'active':''">{{item.jobReq}}</view>
				</view>
				<u-button type="primary" @click="closePostionPost" customStyle="background:#0575FF; font-size:32rpx;" text="确定"></u-button>
			</view>
		</u-popup>
		
		<u-popup
			:show="treatment" 
			:round="10" 
			mode="bottom" 
			:closeable="true" 
			@close="closeTreatment" 
			>
			<view class="but">
				<view class="butTitle">请选择福利待遇</view>
				<view class="list">
					<view v-for="(item,index) in treatmentData" @click="choiceTreatment(index)" :key="index" 
					:class="item.curIndex==1?'active':''">{{item.welfare}}</view>
				</view>
				<u-button type="primary" @click="closeTreatmentData()" customStyle="background:#0575FF; font-size:32rpx;" text="确定"></u-button>
			</view>
		</u-popup>
		
		<!--全部工种-->
		<pop ref="gongzhong" :direction="direction" :is_close="true" :is_mask="true" :width="100">
			 <view class="con-del dis-clm">
				 <view class="cityName">全部工种</view>
				 <view class="checkgongzhongLList row-box" v-if="selectCheckgognzhong.length>0">
					 <view v-for="(se,sc) in selectCheckgognzhong" :key="sc" class="dis-row" @click="delSelectgz(se,sc)">
						 <text>{{se.skillName}}</text><label><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/icon/cc.png"></image></label>
					 </view>
				 </view>
				 <view class="cityList dis-row">
				 	<view class="sheng dis-clm">
				 		<scroll-view scroll-y="true">
				 			<view class="sheng-Lst" v-for="(gzitem,gzindex) in gongzhongList" 
								:key="gzindex" 
								:class="{'shengActive':(gzlevelone==gzindex && isclickgzone == true)}"
								@click="gzTaskLevelone(gzitem,gzindex)">
								{{cutstr(gzitem.skillName,10)}}
							</view>
				 		</scroll-view>
				 	</view>
				 	<view class="leveltwo dis-clm" v-if="gongzhongList[gzlevelone] && gongzhongList[gzlevelone].child">
						<scroll-view scroll-y="true">
							<view class="shi-lst" v-for="(shiItem,shiIndex) in gongzhongList[gzlevelone].child" 
							:key="shiIndex"
							:class="{'shiActive':(gzleveltwo == shiIndex && isclickgztwo == true)}"
							@click="gzTaskLevelTwo(shiItem,shiIndex)"
							style="width: 400rpx;"
							>
								{{shiItem.skillName}}
							</view>
						</scroll-view>
					</view>
			
				 </view>
				 <view class="addres-footer dis-row">
					 <view class="addres-btn" @click="cleanGongZhongIndex">清除</view>
					 <view class="addres-btn" @click="getCheckGongZhong">确定选择</view>
				 </view>
			 </view>
		</pop>
		
	</view>
</template>
<script>
	import store from '@/common/store.js'
	import Index from '@/common/index-model.js'
	import pop from "@/components/ming-pop/ming-map.vue"
	let index=new Index() 
	export default {
		data() {
			return {
				direction:'below',
				xiangmuTempData:{},//上一个页面传过来的数据
				gongzhong:[], //工种信息组合
				addresObj:{},//项目地址的全部信息
				mobile:'',
				telTime: false,
				postion: false,
				treatment: false,
				fileList1: [],
				fileImgUrl:[],//图片
				answerTelDate: [],//联系电话的时间
				selecTimeList:[],
				postionDate: [
					 { "id": 1, "maxVal": "22","curIndex": 1, "minVal": "6", "status": 1, "name": "实名" } 
				],
				selectzhiye:[],
				treatmentData: [
					 { "id": 1, "maxVal": "22","curIndex": 1, "minVal": "6", "status": 1, "name": "包住" } 
				],
				selectfuli:[],
				form: {
					address: '',
					worktype: '',
					workDis: '',
					name: '',
					tel: '',
					teltime: ''
				},
				rules: {},
				isclickgzone:false,//二级工种 是否被点击
				isclickgztwo:false,//三级工种 是否被点击
				gongzhongList:[], //底部弹窗工种列表
				gzlevelone:0, //二级工种 当前选中的序号
				gzleveltwo:0, //三级工种 当前选中的序号
				selectCheckgognzhong:[],//选中的工种
			}
		},
	    components:{
			pop
		},
		onLoad(opt) {
			this.getpostionDate() //职业配置
			this.getTreatmentData() //福利待遇配置
			this.GetanswerTelDate() //获取配置时间
			this.getQueryType()
			if(!opt.str){
				index.show_tips('请先去选择项目地址等信息')
				setTimeout(()=>{
					index.navigate_back(1)
				},500)
				return false
			}
			console.log(opt.str)
			this.xiangmuTempData = JSON.parse(opt.str)
			console.log(this.xiangmuTempData);
			this.gongzhong = this.xiangmuTempData.gongzhong // 工种信息
			this.addresObj = this.xiangmuTempData.addres  //地址信息
			// this.form.address = this.xiangmuTempData.xmAddTem
			this.form.address = this.addresObj.addressName
			this.form.worktype = this.xiangmuTempData.gzText
			this.form.workDis = this.xiangmuTempData.contentText
			
			
			
			if(this.xiangmuTempData.selectzhiye){
				this.selectzhiye = this.xiangmuTempData.selectzhiye
			}
			if(this.xiangmuTempData.selectfuli){
				this.selectfuli = this.xiangmuTempData.selectfuli
			}
			if(this.xiangmuTempData.username){
				this.form.name = this.xiangmuTempData.username
			}
			if(this.xiangmuTempData.tel){
				this.form.tel = this.xiangmuTempData.tel
				this.form.mobile = this.xiangmuTempData.tel
			}
			if(this.xiangmuTempData.timeList){
				this.selecTimeList = this.xiangmuTempData.timeList
				this.form.teltime = this.xiangmuTempData.timeshow
			}
			//工种明细页面传值
			//console.log(opt.currList,'=====opt.currList===')
			if(opt.currList){
				//console.log(JSON.parse(opt.currList),'====99999=====')
				let arrobject = JSON.parse(opt.currList)
				let crrindex =this.xiangmuTempData.NewIndex
				this.gongzhong[crrindex].child = arrobject
			}
			this.getUserInfo()
			
		},
		methods: {
			//添加工种明细
			addGongzhong(item,kv) {
				let newstr={
					addres:this.addresObj, //对象
					gongzhong:this.gongzhong, //数组
					contentText:this.form.workDis,//工作内容
					xmAddTem:this.form.address, //临时显示的项目地址
					gzText:this.form.worktype,  //临时显示的工种信息
					selectzhiye:this.selectzhiye,//选中的职业信息
					selectfuli:this.selectfuli,//选中的福利信息
					username:this.form.name,
					tel:this.form.tel,
					NewIndex:kv, //添加工种明细的下标
					gongzhongChild:item.child?item.child:null, //是否有子对象
					timeList:this.selecTimeList, //选中的接电话的时间	
					timeshow:this.form.teltime  //临时显示的接电话的时间
				}
				let url="../release/checkGongzhong?str="+JSON.stringify(newstr)+"&type=add"
				index.redirectto(url)
			},
			//文本内容
			textareaNo() {
				let newstr={
					addres:this.addresObj, //对象
					gongzhong:this.gongzhong, //数组
					contentText:this.form.workDis,//工作内容
					xmAddTem:this.form.address, //临时显示的项目地址
					gzText:this.form.worktype,  //临时显示的工种信息
					selectzhiye:this.selectzhiye,//选中的职业信息
					selectfuli:this.selectfuli,//选中的福利信息
					username:this.form.name,
					tel:this.form.tel,
					timeList:this.selecTimeList, //选中的接电话的时间	
					timeshow:this.form.teltime  //临时显示的接电话的时间
				}
				let url="../../pagesB/perfectWork/introduce?str="+JSON.stringify(newstr)+"&type=pdnode"
				index.navigate_to(url)
			},
			navAddMaps() {
				let newstr={
					addres:this.addresObj, //对象
					gongzhong:this.gongzhong, //数组
					contentText:this.form.workDis,//工作内容
					xmAddTem:this.form.address, //临时显示的项目地址
					gzText:this.form.worktype,  //临时显示的工种信息
					selectzhiye:this.selectzhiye,//选中的职业信息
					selectfuli:this.selectfuli,//选中的福利信息
					username:this.form.name,
					tel:this.form.tel,
					timeList:this.selecTimeList, //选中的接电话的时间	
					timeshow:this.form.teltime  //临时显示的接电话的时间
				}
				let url="../release/addMap?str="+JSON.stringify(newstr)+"&type=padd"
				index.navigate_to(url)
			},
			//修改电话号码
			addNewPhone() {
				if(this.form.name == ''){
					index.show_tips('请先填写姓名')
					return false;
				}
				let newstr={
					addres:this.addresObj, //对象
					gongzhong:this.gongzhong, //数组
					contentText:this.form.workDis,//工作内容
					xmAddTem:this.form.address, //临时显示的项目地址
					gzText:this.form.worktype,  //临时显示的工种信息
					selectzhiye:this.selectzhiye,//选中的职业信息
					selectfuli:this.selectfuli,//选中的福利信息
					username:this.form.name,
					tel:this.form.tel,
					timeList:this.selecTimeList, //选中的接电话的时间	
					timeshow:this.form.teltime  //临时显示的接电话的时间
				}
				let url="./editPhone?str="+JSON.stringify(newstr)+'&type=add'
				index.redirectto(url)
				//console.log(2,'===222===')
			},
			sendnow(value) {
				uni.showLoading({
					title:'加载中...',
					duration:2000
				})
			   let tempArr=[]
			   this.gongzhong.forEach((item,index)=>{
					tempArr.push({
						"level2":item.pid,
						"level3":item.id,
						"composition":(item.child&&item.child.personId)?item.child.personId:'',
						"personNum":(item.child&&item.child.personNumId)?item.child.personNumId:'',
						"settlementType":(item.child&&item.child.countId)?item.child.countId:'',
						"timeLimit":(item.child&&item.child.gongqiId)?item.child.gongqiId:'',
						"ageReq":(item.child&&item.child.ageId)?item.child.ageId:'',
						"salary":(item.child&&item.child.gznum)?item.child.gznum:'',
						"unit":(item.child&&item.child.gztypeid)?item.child.gztypeid:''
					})
			   })
			   let ids=''
			   for(let i=0;i<this.selectzhiye.length;i++){
				   if(i==(this.selectzhiye.length-1)){
					   ids+=this.selectzhiye[i].id
				   }else{
					    ids+=this.selectzhiye[i].id+','
				   }
			   }
			   let flIds=''
			   for(let i=0;i<this.selectfuli.length;i++){
				   if(i==(this.selectfuli.length-1)){
					   flIds+=this.selectfuli[i].id
				   }else{
						flIds+=this.selectfuli[i].id+','
				   }
			   }
			   let telIds=""
			   for(let i=0;i<this.selecTimeList.length;i++){
				   if(i==(this.selecTimeList.length-1)){
					   telIds+=this.selecTimeList[i].id
				   }else{
						telIds+=this.selecTimeList[i].id+','
				   }
			   }
			   if(this.form.workDis == ''){
				   index.show_tips('工作描述不能为空')
				   return false
			   }
			   if(this.form.name == '' || this.form.mobile == ''){
				   index.show_tips('联系人姓名或者电话不能为空')
				   return false
			   }
				let sends={
					"time":1,
					"address":this.addresObj.addressName, //必填
					"requiredTypeOfWork":tempArr,//所需工种 //必填
					"workDesc":this.form.workDis, //工作描述
					"lon":this.addresObj.lon, //必填
					"lat":this.addresObj.lat, //必填
					"cityId":this.addresObj.cityId, //必填
					"areaId":this.addresObj.areaId, //必填
					"type":0,
					"jobReqIds":ids,//职位要求
					"welfareIds":flIds,//福利待遇
					"contactsName":this.form.name,
					"contactsMobile":this.form.mobile,
					"contactsSection":telIds, //接电话时间
					"urlList":this.fileImgUrl
					// "url":''
				}

				index.getPublicUserMember(sends,'client/job/recruitment/information','post',res=>{
					if(res.data.code == 200 && res.data.success){
						uni.hideLoading()
						index.show_tips('发布好活成功')
						setTimeout(()=>{
							if(value==1){
								index.redirectto('/pagesC/jobTop/index?id='+res.data.result);
							}else{
								index.switch_tab('../../pages/index/index')
							}
						},1000)
					}else{
						uni.hideLoading()
						index.show_tips(res.data.message);
						return false
					}
				})
			},
			//接电话时间
			GetanswerTelDate() {
				index.getPublicUserMember({},'client/public/find/section','get',res=>{
					if(res.data.code == 200 && res.data.success){
						let arr = res.data.result
						if(arr.length>0){
							for(let i=0;i<arr.length;i++){
								arr[i].curIndex = 0
							}
							this.answerTelDate = arr
						}
					}
				})
			},
			//福利待遇
			getTreatmentData() {
				index.getPublicUserMember({},'client/public/find/welfare','get',res=>{
					if(res.data.code == 200 && res.data.success){
						let arr = res.data.result
						if(arr.length>0){
							for(let i=0;i<arr.length;i++){
								arr[i].curIndex = 0
							}
							this.treatmentData = arr
						}
					}
				})
			},
			//职位要求配置 postionDate
			getpostionDate() {
				index.getPublicUserMember({},'client/public/find/job/req','get',res=>{
					if(res.data.code == 200 && res.data.success){
						let arr = res.data.result
						if(arr.length>0){
							for(let i=0;i<arr.length;i++){
								arr[i].curIndex = 0
							}
							this.postionDate = arr
						}
					}
				})
			},
			getUserInfo(){
				index.getPublicUserMember({},'/client/individual/homePage','get',res=>{
					if(res.data.code == 200 && res.data.success){
						if(!this.form.tel){
							this.form.mobile=res.data.result.mobile;
							this.form.tel = res.data.result.mobile
						}
						if(!this.form.name){
							this.form.name=res.data.result.nickName;
						}
					}else{
						index.show_tips(res.data.message);
						return false
					}
				})
				
			},
			choiceDate(i) {
				if(i==0){
					if(this.answerTelDate[i].curIndex==1){
						this.answerTelDate[i].curIndex=0;
					}else{
						this.answerTelDate[i].curIndex=1;
						this.answerTelDate.forEach((item,index)=>{
							if(index!=i){
								this.answerTelDate[index].curIndex=0;
							}
						})
					}
				}else{
					if(this.answerTelDate[i].curIndex==1){
						this.answerTelDate[i].curIndex=0;
					}else{
						this.answerTelDate[i].curIndex=1;
						this.answerTelDate[0].curIndex=0;
					}
				}				
			},
			closeTelTime() {
			    this.telTime = false;
				this.answerTelDate.forEach((item,index)=>{
					if(item.curIndex==1){
						this.form.teltime=item.name;
					}
				})
			},
			closeTelTimeSure() {
				this.selecTimeList = []
				this.form.teltime = ''
				for(let i=0;i<this.answerTelDate.length;i++){
					if(this.answerTelDate[i].curIndex == 1){
						if(this.selecTimeList.length<2){
							this.selecTimeList.push(this.answerTelDate[i])
						}else{
							index.show_tips('接电话时间不能超过2个')
							return false
						}
						
					}
				}
				if(this.selecTimeList.length == 0){
					index.show_tips('请选择时间段')
					return false
				}
				// this.selecTimeList.forEach(item=>{
				// 	this.form.teltime +=item.name+','
				// })
				for(let j=0;j<this.selecTimeList.length;j++){
					if(j==(this.selecTimeList.length-1)){
						this.form.teltime +=this.selecTimeList[j].name
					}else{
						this.form.teltime +=this.selecTimeList[j].name+','
					}
				}
				this.telTime = false;
			},
			openTelTime() {
			    this.telTime = true;
			},
			
			closePostion() {
			    this.postion = false;
				this.answerTelDate.forEach((item,index)=>{
					if(item.curIndex==1){
						this.form.teltime=item.name;
					}
				})
			},
			openPostion() {
			    this.postion = true;
			},
			choicePostion(i) {
				if(this.postionDate[i].curIndex==1){
					this.postionDate[i].curIndex=0;
				}else{
					this.postionDate[i].curIndex=1;
				}			
			},
			//确定选择的职业
			closePostionPost() {
				this.selectzhiye = []
				for(let i=0;i<this.postionDate.length;i++){
					if(this.postionDate[i].curIndex){
						this.selectzhiye.push(this.postionDate[i])
					}
				}
				if(this.selectzhiye.length == 0){
					index.show_tips('请选择职业')
					return false
				}
				this.postion = false
			},			
			closeTreatment() {
				this.treatment = false;
				this.answerTelDate.forEach((item,index)=>{
					if(item.curIndex==1){
						this.form.teltime=item.name;
					}
				})
			},
			//确定选择的福利
			closeTreatmentData(cv) {
				this.selectfuli = []
				//console.log(this.treatmentData,'====treatmentData=')
				for(let i=0;i<this.treatmentData.length;i++){
					if(this.treatmentData[i].curIndex){
						this.selectfuli.push(this.treatmentData[i])
					}
				}
				if(this.selectfuli.length == 0){
					index.show_tips('请选择福利待遇')
					return false
				}
				this.treatment = false
			},
			openTreatment() {
				this.treatment = true;
			},
			choiceTreatment(i) {
				if(this.treatmentData[i].curIndex==1){
					this.treatmentData[i].curIndex=0;
				}else{
					this.treatmentData[i].curIndex=1;
				}			
			},	

			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
				this.fileImgUrl.splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				if(this.form.name=='' || this.form.tel ==''){
					index.show_tips('请先填完必填信息再上传图片')
					return false
				}
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: index.img_url+'client/public/upload?type=headPicture&file='+url, // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						header: {
							'X-Access-Token':uni.getStorageSync('token'),
							'Login-Type':'client'
						},
						success: (res) => {
							this.fileImgUrl.push({'url':JSON.parse(res.data).result.url})
							setTimeout(() => {
								resolve(res.data.data)
							}, 1000)
						}
					});
				})
			},
			cutstr(str, len) {
				var str_length = 0;
				var str_len = 0;
				var str_cut = new String();
				str_len = str.length;
				for (var i = 0; i < str_len; i++) {
					var a = str.charAt(i);
					str_length++;
					if (escape(a).length > 4) {
						//中文字符的长度经编码之后大于4  
						str_length++;
					}
					str_cut = str_cut.concat(a);
					if (str_length >= len) {
						str_cut = str_cut.concat("...");
						return str_cut;
					}
				}
				//如果给定字符串小于指定长度，则返回源字符串；  
				if (str_length < len) {
					return str;
				}
			},
			//查询工种
			showGZ() {
				this.$refs.gongzhong.show()
			},
			getQueryType() {
				let types= "construction"
				index.getPublicMember({},'client/skills/list/'+types,'get',res=>{
					if(res.data.success && res.data.code == 200){
						let arr = res.data.result
						let gzarr=[];
						if(arr.length>0){
							for(let i=0;i<arr.length;i++){
								if(arr[i].slevel == 2){
									gzarr.push(arr[i]);
								}
							}
							//console.log(gzarr,'=====gzarr====gzarr')
							//把三级工种压到二级工种里面
							if(gzarr.length>0){
								for(let j=0;j<gzarr.length;j++){
									gzarr[j].child = []
									for(let m=0;m<arr.length;m++){
										if(arr[m].pid == gzarr[j].id && arr[m].slevel == 3){
											gzarr[j].child.push(arr[m])
										}
									}
								}
							}
							this.gongzhongList = gzarr;
							//console.log(this.gongzhongList,'----list====')
						}else{
							this.gongzhongList=[]
						}
					}else{
						this.gongzhongList = []
					}
				})
			},
			//点击工种二级类型 切换下标
			gzTaskLevelone(item,gzindex) {
				this.gzlevelone = gzindex
				this.gzleveltwo = 0
				this.isclickgzone = true
				this.isclickgztwo = false
			},
			//切换三级工种 类型 下标
			gzTaskLevelTwo(item,gzindex) {
				  this.isclickgztwo = true
				  if(this.selectCheckgognzhong.length == 0){
					  this.gzleveltwo = gzindex
					  this.selectCheckgognzhong.push(item)
				  }else{
					
					let issure = false
					for(let i=0;i<this.selectCheckgognzhong.length;i++){
						if(this.selectCheckgognzhong[i].id == item.id){
							issure=true
						}
					}
					console.log(this.selectCheckgognzhong.length,issure)
					if(issure == false){
						if(this.selectCheckgognzhong.length<3){
							this.selectCheckgognzhong.push(item)
							this.gzleveltwo = gzindex
						}else{
							index.show_tips('所选工种不能超过3个')
							return false
						}
					}else{
						index.show_tips('改工种已被选中')
						return false
					}
				  }
			},
			//移除选中的工种
			delSelectgz(se,sc) {
				if(this.selectCheckgognzhong.length>0){
					this.selectCheckgognzhong.splice(sc,1)
					//delete this.selectCheckgognzhong[sc]
				}
			},
			//清空选中的工种
			cleanGongZhongIndex() {
				this.gzlevelone = 0
				this.gzleveltwo = 0
				this.selectCheckgognzhong = []
				// this.form.objType = ''
				this.form.worktype = ''
				this.isclickCitysheng = false
				this.isclickCityshi = false 
				this.isclickCityqu = false
				//this.$refs.gongzhong.close()
			},
			//确定选中的工种进行查询
			getCheckGongZhong() {
				if(this.selectCheckgognzhong.length == 0){
					index.show_tips('请先去选择要查询的工种')
					return false
				}
				let one=[],two=[]
						//console.log(this.selectCheckgognzhong,'=====this.selectCheckgognzhong===');
						this.form.worktype = ''
				for(let i = 0;i<this.selectCheckgognzhong.length;i++){
					if(i == (this.selectCheckgognzhong.length-1)){
						this.form.worktype +=this.selectCheckgognzhong[i].skillName
					}else{
						this.form.worktype +=this.selectCheckgognzhong[i].skillName +','
					}
				}

				this.gongzhong = this.selectCheckgognzhong
				this.$refs.gongzhong.close()
			},
			
		}
	}
</script>

<style lang="scss" scoped>
@import url("index.css");
@import url("@/static/css/publics.css");

::v-deep {
  .u-navbar--fixed {	  
	  background: #fff;
    // background-image: linear-gradient(to bottom, #42cdff, #0288ff);
    & > view {
      background: transparent !important;
    }
    .leftText {
      color: #000;
    }
  }
}

.content{
	
}

.form{
	padding: 20rpx 20rpx 0rpx 20rpx;
	background: #fff;
	
	.u-form-item {
		
	}
	.imageUpload{
		margin-top: 26rpx;
		view:nth-child(1){
			color: #424242;
		}
		view:nth-child(2){
			color: #A1A1A1;
			font-size: 24rpx;
			line-height: 44rpx;
			margin-bottom: 10rpx;
		}
	}
}
.relBut{
	padding: 100rpx 0rpx 60rpx 0rpx;
	display: flex;
	view:nth-child(1){
		flex: 1;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		background: #E4F0FF;
		color: #0575FF;
		border-radius: 6rpx;
		margin-right: 22rpx;
	}
	view:nth-child(2){
		flex: 1;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		background: #0575FF;
		color: #fff;
		border-radius: 6rpx;
	}
}

.work_type {
	align-items: baseline;
	background: #E4F0FF;
	margin-bottom: 20rpx;
	padding: 20rpx;
	.top {
		align-items: center;
		overflow: hidden;
		width: 100%;
		.work_type_name{
			float: left;
			display: flex;
			view:nth-child(1) {
				color: #424242;
				font-weight: bold;
				height: 40rpx;
				line-height: 40rpx;
			}
			view:nth-child(2) {
				color: #FFFFFF;
				font-weight: bold;
				background: #0575FF;
				height: 40rpx;
				line-height: 40rpx;
				width: 72rpx;
				border-radius: 6rpx;
				text-align: center;
				margin-left: 16rpx;
			}
		}
		.status{
			float: right;
			color: #FF5964;
			font-weight: bold;
			height: 40rpx;
			line-height: 40rpx;
		}
	}
	.bottom {
		color: #A1A1A1;
		font-size: 24rpx;
		margin-top: 20rpx;
		//overflow: hidden;
		display: flex;
		view{
			padding: 0 15rpx;
			border-left: 1px solid #A1A1A1;
			height: 30rpx;
			line-height: 30rpx;
			font-size: 26rpx;
		}
		.t1{
			color: #FF5964;
			font-size: 26rpx;
		}
		view:first-child{
			padding-left: 0;
			border: none;
		}
	}
}
</style>